package me.yricky.mayu.utils.misc;

/**
 * @author Yricky
 * @date 2022/4/21
 */
public final class MemIntMatrix implements IIntMatrix {
    private final int[][] mat;
    private final int row,col;
    public MemIntMatrix(int row,int col){
        mat = new int[row][col];
        this.row = row;
        this.col = col;
    }

    @Override
    public int getRow() {
        return row;
    }

    @Override
    public int getCol() {
        return col;
    }

    @Override
    public int get(int row,int col,int def){
        if(row<0 || col<0 || row >= this.row || col>= this.col){
            return def;
        }
        return mat[row][col];
    }

    @Override
    public void set(int row,int col,int value){
        if(row<0 || col<0 || row >= this.row || col>= this.col){
            return;
        }
        mat[row][col] = value;
    }


}
